package com.github.bridge;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import lombok.extern.slf4j.Slf4j;
import org.dromara.dynamictp.core.spring.EnableDynamicTp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

@Slf4j
@EnableAsync
@EnableDynamicTp
@EnableScheduling
@SpringBootApplication
public class SignatureBridgeServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(SignatureBridgeServiceApplication.class, args);
    }

    @Bean
    public Snowflake snowflake() {
        int datacenterId = RandomUtil.randomInt(32);
        int workerId = RandomUtil.randomInt(32);
        log.info("datacenterId:{},workerId:{}", datacenterId, workerId);
        return IdUtil.getSnowflake(workerId, datacenterId);
    }
}
